package com.youku.plugins.controlbarV4.view.components
{
   import flash.display.Sprite;
   import flash.display.DisplayObject;
   import com.youku.utils.AssetUtil;
   import flash.display.MovieClip;
   import com.youku.baseUI.TweenSlider;
   import fl.controls.SliderDirection;
   import flash.events.MouseEvent;
   import com.youku.plugins.controlbarV4.view.events.SoundSliderEvent;
   
   public class SoundSliderMini extends SoundSlider
   {
      
      public function SoundSliderMini() {
         super();
      }
      
      protected var _sliderPart:Sprite;
      
      protected var _background:DisplayObject;
      
      override protected function createItems() : void {
         this._sliderPart = new Sprite();
         this._background = AssetUtil.getAsset("C_Sound2_bg");
         _soundIcons = new Array();
         var _loc1_:MovieClip = AssetUtil.getAsset("C_Sound2_icon_0") as MovieClip;
         _loc1_.buttonMode = true;
         _loc1_.useHandCursor = true;
         _soundIcons.push(_loc1_);
         var _loc2_:MovieClip = AssetUtil.getAsset("C_Sound2_icon_1") as MovieClip;
         _loc2_.buttonMode = true;
         _loc2_.useHandCursor = true;
         _soundIcons.push(_loc2_);
         _ball = AssetUtil.getStyleButton("C_Sound2_ball");
         AssetUtil.restoreButtonSize(_ball);
         _soundSlider = new TweenSlider();
         _soundSlider.direction = SliderDirection.HORIZONTAL;
         _soundSlider.setStyle("sliderTrackSkin",AssetUtil.getAsset("C_Sound2_slider"));
         _soundSlider.setStyle("sliderTrackDisabledSkin",AssetUtil.getAsset("C_Sound2_slider"));
         _soundSlider.setStyle("tickSkin",new Sprite());
         _soundSlider.setStyle("thumbUpSkin",AssetUtil.getAsset("C_Sound_ball_up"));
         _soundSlider.setStyle("thumbOverSkin",AssetUtil.getAsset("C_Sound_ball_over"));
         _soundSlider.setStyle("thumbDownSkin",AssetUtil.getAsset("C_Sound_ball_down"));
         _soundSlider.setStyle("thumbDisabledSkin",AssetUtil.getAsset("C_Sound_ball_disable"));
         _soundSlider.updateSize();
         _soundSlider.minimum = 0;
         _soundSlider.maximum = 100;
         _soundSlider.tickInterval = 1;
         _soundSlider.liveDragging = true;
         _soundSlider.rotation = -90;
         this._sliderPart.addChild(this._background);
         this._sliderPart.addChild(_soundSlider);
         addChild(this._sliderPart);
         var _loc3_:* = 0;
         while(_loc3_ < _soundIcons.length)
         {
            addChild(_soundIcons[_loc3_] as DisplayObject);
            _loc3_++;
         }
         this._background.x = this._background.y = 0;
         _soundSlider.x = 9;
         _soundSlider.y = this._background.height - 8;
         this._sliderPart.x = 0;
         this._sliderPart.y = 0 - this._sliderPart.height;
         _loc3_ = 0;
         while(_loc3_ < _soundIcons.length)
         {
            (_soundIcons[_loc3_] as DisplayObject).x = 0;
            (_soundIcons[_loc3_] as DisplayObject).y = 0;
            _loc3_++;
         }
         this._sliderPart.visible = false;
         this.addEventListener(MouseEvent.ROLL_OVER,this.onRollOver);
         this.addEventListener(MouseEvent.ROLL_OUT,this.onRollOut);
      }
      
      private function onRollOut(param1:MouseEvent) : void {
         this._sliderPart.visible = false;
      }
      
      private function onRollOver(param1:MouseEvent) : void {
         this._sliderPart.visible = true;
      }
      
      override protected function setSoundFrame() : void {
         var _loc1_:* = 0;
         while(_loc1_ < _soundIcons.length)
         {
            _soundIcons[_loc1_].visible = false;
            _loc1_++;
         }
         var _loc2_:* = 0;
         var _loc3_:Number = _mute?0:data;
         if(_loc3_ == 0)
         {
            _loc2_ = 0;
         }
         else
         {
            _loc2_ = 1;
         }
         _soundIcons[_loc2_].visible = true;
      }
      
      override protected function filterUI(param1:Boolean) : void {
      }
      
      override protected function onSoundIconClick(param1:MouseEvent) : void {
         var _loc2_:* = !_mute;
         setMute(_loc2_);
         var _loc3_:SoundSliderEvent = new SoundSliderEvent(SoundSliderEvent.MUTE_CHANGED);
         _loc3_.mute = _loc2_;
         dispatchEvent(_loc3_);
         _loc3_ = new SoundSliderEvent(SoundSliderEvent.CHANGED);
         _loc3_.volume = _mute?0:data;
         _loc3_.record = false;
         dispatchEvent(_loc3_);
      }
   }
}
